﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using OfficeOpenXml;
using publico;
using negocios;
using objetos;

namespace softsales.pagina.order_book_truck
{
    public partial class order_book_truck_incluir : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (PUB_SESSAO.Logado())
            {

            }
        }


        protected void BTN_UPLOAD_Click(object sender, EventArgs e)
        {

            Upload();
        }

        private void Upload()
        {
            if (FU_UPLOAD.HasFile)
            {

                try
                {

                    String path = MapPath("~/upload");

                    if (!publico.PUB_FUNCOES.ExisteDiretorio(path))
                    {

                        publico.PUB_FUNCOES.CriarDiretorio(path);

                    }

                    HttpPostedFile pf = FU_UPLOAD.PostedFile;

                    string arquivo = FU_UPLOAD.FileName;

                    FU_UPLOAD.SaveAs(@path + "\\" + arquivo);

                    LBL_ARQUIVO.Text = string.Format("Nome do Arquivo : {0} , tamanho : {1}, tipo : {2}", pf.FileName, pf.ContentLength, pf.ContentType);



                    FileInfo fi = new FileInfo(@path + "\\" + arquivo);

                    DataSet ds = new DataSet();
                    DataTable dt = new DataTable();

                    BLL_TB_ORDER_BOOK_TRUCK b_tb_order_book_truck_import = new BLL_TB_ORDER_BOOK_TRUCK();



                    b_tb_order_book_truck_import.Importar(fi);


                    GRV_TRUCK.DataSource = b_tb_order_book_truck_import.SelecionarLista();

                    GRV_TRUCK.DataBind();


                    PNL_ORDER_BOOK_TRUCK.Visible = true;

                }

                catch (Exception)
                {

                    throw;

                }

            }

            Master.MSG_SUCESSO("Upload realizado com sucesso.");
        }


    }
}